package com.winderinfo.yikaotianxia.ui.report;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.winderinfo.yikaotianxia.R;
import com.winderinfo.yikaotianxia.core.utils.MapUtil;
import com.winderinfo.yikaotianxia.ui.mockexam.AnswerBean;
import com.winderinfo.yikaotianxia.ui.mockexam.CardBean;

import java.util.List;

public class ReportAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private Context context;
    private List<ReportBean.YkScoreBean.YkAnswerRecordsBean> list;

    public ReportAdapter(Context context, List<ReportBean.YkScoreBean.YkAnswerRecordsBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_tii, viewGroup, false);
        SelectedViewHolder selectedViewHolder = new SelectedViewHolder(view);
        return selectedViewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, final int i) {
        final SelectedViewHolder selectedViewHolder = (SelectedViewHolder) viewHolder;
        String complete = list.get(i).getComplete();
        if (complete.equals("0")) {
            selectedViewHolder.tii_a.setVisibility(View.VISIBLE);
            selectedViewHolder.tii_a.setText((i + 1) + "");
        } else if (complete.equals("1")){
            selectedViewHolder.tii_b.setVisibility(View.VISIBLE);
            selectedViewHolder.tii_b.setText((i + 1) + "");
        }else {
            selectedViewHolder.tii_c.setVisibility(View.VISIBLE);
            selectedViewHolder.tii_c.setText((i + 1) + "");
        }
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class SelectedViewHolder extends RecyclerView.ViewHolder {

        private final TextView tii_a, tii_b, tii_c;

        public SelectedViewHolder(@NonNull View itemView) {
            super(itemView);
            tii_a = itemView.findViewById(R.id.tii_a);
            tii_b = itemView.findViewById(R.id.tii_b);
            tii_c = itemView.findViewById(R.id.tii_c);
        }
    }

    //接口回调
    public interface OnopId {
        void getId(String id);
    }

    public OnopId onopId;

    public void setOnopId(OnopId onopId) {
        this.onopId = onopId;
    }

}
